from pymongo import MongoClient

connect = MongoClient("mongodb://root:123@127.0.0.1:27017/admin")

my_db = connect["mofang"]
my_collections = my_db["my_collections"]

# document = {"name":"bobo","mobile":"15831682918","age":16,"sex":True}
# ret = my_collections.insert_one(document)
# print(ret.inserted_id)

data_list = [
    { "name": "xiaobai", "mbile": "13322345678","age":16,"sex":False},
    { "name": "xiaohei", "mobile": "13322345678","age":20,"sex":True},
    { "name": "xiaohong", "mobile": "13322345678","age":13,"sex":False},
    { "name": "xiaolan", "mobile": "13322345678","age":17,"sex":True},
    { "name": "xiaolv", "mobile": "13322345678","age":17,"sex":True},
    { "name": "xiaolong", "mobile": "13322345678","age":16,"sex":False},
    { "name": "xiaofei", "mobile": "13322345678","age":18,"sex":True},
]

ret = my_collections.insert_many(data_list)
print(ret.inserted_ids)




